package net.anzhuo.service.impl;

import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.dao.GsCorpothersinfoMapper;
import net.anzhuo.dao.GsZiZhiMapper;
import net.anzhuo.entity.GsCorpothersinfo;
import net.anzhuo.entity.GsZiZhi;
import net.anzhuo.service.GsCorpothersinfoService;
import net.anzhuo.service.GsZiZhiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GsZiZhiServiceImpl implements GsZiZhiService {

	@Autowired
	private GsZiZhiMapper gsZiZhiMapper;

	@Override
	public PaginationVO<GsZiZhi> getListWithPage(GsZiZhi gsZiZhi) {
		PaginationVO<GsZiZhi> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsZiZhiMapper.getListWithPage(gsZiZhi));
		paginationVO.setTotalCount(gsZiZhiMapper.getCount(gsZiZhi));
		paginationVO.setTotalPage((gsZiZhiMapper.getCount(gsZiZhi) + gsZiZhi.getPageSize() -1)  / gsZiZhi.getPageSize());
		paginationVO.setPageNo(gsZiZhi.getPageNo());
		return paginationVO;
	}

	@Override
	public GsZiZhi getById(Long id) {
		return gsZiZhiMapper.getById(id);
	}

	@Override
	public List<GsZiZhi> getList() {
		return gsZiZhiMapper.getList();
	}

	@Override
	public List<GsZiZhi> getList(GsZiZhi gsZiZhi) {
		return gsZiZhiMapper.getListByQuery(gsZiZhi);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsZiZhi gsZiZhi) {
		gsZiZhiMapper.update(gsZiZhi);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsZiZhi gsZiZhi) {
		gsZiZhiMapper.save(gsZiZhi);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(GsZiZhi gsZiZhi) {
		gsZiZhiMapper.delete(gsZiZhi);
	}

	@Override
	public List<GsZiZhi> getByMd5(String md5) {
		return gsZiZhiMapper.getByMd5(md5);
	}
}
